package logging

import (
	"os"

	"github.com/sirupsen/logrus"
	"gopkg.in/natefinch/lumberjack.v2"
)

var logger = logrus.New()

func init() {
	// Set the output of logs to both stdout and a file
	logger.SetOutput(&lumberjack.Logger{
		Filename:   "logs/app.log",
		MaxSize:    10, // megabytes
		MaxBackups: 3,
		MaxAge:     28,   // days
		Compress:   true, // disabled by default
	})

	// Also log to stdout
	logger.SetOutput(os.Stdout)

	// Set the log level
	logger.SetLevel(logrus.InfoLevel)

	// Set the log format
	logger.SetFormatter(&logrus.TextFormatter{
		FullTimestamp: true,
	})
}

func Info(args ...interface{}) {
	logger.Info(args...)
}

func Warn(args ...interface{}) {
	logger.Warn(args...)
}

func Error(args ...interface{}) {
	logger.Error(args...)
}

func Debug(args ...interface{}) {
	logger.Debug(args...)
}
